<?php
/**
 * Created by PhpStorm.
 * User: patric kwu
 * Date: 2020/10/30
 * Time: 10:59
 */
namespace App\Http\Controllers\Backend;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use SwooleTW\Http\Websocket\Facades\Websocket;

class BaseController extends Controller
{
    protected $current_room;            //client socket room name

    protected $room_id;                 //live room id

    protected $socket_room;             //backend socket room name

    public function __construct(Request $request)
    {
        $room_id    =   $request->query->get('room_id');

        /**
         * setting current connection room name
         */
        $this->current_room =   (Websocket::getUserId() ?? 70);  //'c61a8478-9793-47a9-a31c-35dc52a073d7'

        $this->room_id      =   $room_id ?? 70;

        $this->socket_room  =   'socket_' . $this->current_room;
    }
}
